<extend name="Base/common"/>

<block name="body">
  <form action="{:U('seckill/add')}" id="J_checkout_form" method="post">
    <div class="row">
      <div class="col-xs-12">
        <!-- 收货地址 -->
        <div class="page-header">
          <h3>收货地址</h3>
        </div>
        <div class="row" id="J_address_list">
          <volist name="receiver" id="vo">
            <php>$selected = ($vo['is_default'] == 1 || count($receiver) == 1) ? 1 : 0;</php>
            <div class="col-xs-3 address-item <eq name="selected" value="1">selected</eq> J_address_item" data-id="{$vo.id}" data-name="{$vo.name}" data-mobile="{$vo.mobile}" data-province="{$vo.province}" data-district="{$vo.district}" data-city="{$vo.city}" data-area="{$vo.area}" data-address="{$vo.address}" data-zipcode="{$vo.zipcode}" data-is_default="{$vo.is_default}">
              <dl>
                <dt><strong class="itemConsignee">{$vo.name}</strong></dt>
                <dd>
                  <p class="itemRegion"><eq name="vo.is_default" value="1"><em class="text-danger">[默认]</em></eq>{$vo.area}{$vo.address}({$vo.zipcode})</p>
                  <p class="tel itemTel">{$vo.mobile}</p>
                  <span class="edit-btn btn btn-xs btn-positive J_edit_address">修改</span>
                </dd>
                <dd style="display:none">
                  <input type="radio" name="receiver_id" class="J_receiver_id" value="{$vo.id}" <eq name="selected" value="1">checked="checked"</eq>>
                </dd>
              </dl>
            </div>
          </volist>
          <div class="col-xs-3 address-item use-new-addr J_address_item J_add_address" id="useNewAddr" data-state="off">
            <dl>
              <span class="icon icon-add"></span>使用新地址
            </dl>
          </div>
        </div>
        <div class="address-edit-box" id="J_address_edit_box">
          <div class="bd">
            <input type="hidden" name="id" id="J_address_id" value="">
            <div class="item">
              <input type="text" name="name" id="J_input_name" class="input" placeholder="收货人姓名" maxlength="15" value="">
              <p class="tip-msg tipMsg" style="display: none;"></p>
            </div>
            <div class="item">
              <input type="text" name="mobile" id="J_input_mobile" class="input" placeholder="手机号码" maxlength="11" value="">
              <p class="tip-msg tipMsg" style="display: none;"></p>
            </div>
            <div class="item item-area" id="J_address_area">加载中...</div>
            <div class="item">
              <textarea name="address" class="input-area" id="J_input_address" placeholder="路名或街道地址，门牌号"></textarea>
              <p class="tip-msg tipMsg" style="display: none;"></p>
            </div>
            <div class="item">
              <input type="text" name="zipcode" id="J_input_zipcode" class="input" placeholder="邮政编码" maxlength="6" value="">
              <p class="tip-msg tipMsg" style="display: none;"></p>
            </div>
            <div class="item set-default">
              <label for="J_is_default"><input type="checkbox" name="is_default" id="J_is_default" value="1">设为默认收货地址</label>
              <p class="tip-msg tipMsg" style="display: none;"></p>
            </div>
          </div>
          <div class="ft clearfix">
            <button type="button" class="btn btn-sm" id="J_edit_address_cancel">重新选择地址</button>
            <a href="javascript:;" class="btn btn-sm btn-positive" id="J_edit_address_ok">确认收货地址</a>
          </div>
        </div>
        
        
        <div class="page-header">
          <h3>订单备注</h3>
        </div>
        <div class="row">
          <div class="col-xs-3" data-state="off">
            <textarea style="width:563px;" name="memo" class="form-control" placeholder="请将购买需求在备注中做详细说明"></textarea>
          </div>
        </div>
        <!-- 发票信息 -->
        <if condition="C('IS_RECEIPT') eq 1">
          <div class="page-header">
            <h3>发票信息</h3>
          </div>
          <div class="row">
            <div id="invoice_html" class="col-xs-3 form-control" data-state="off">
              <div class="col-xs-3">
                  <span> 不开发票</span>
              </div>
              <div><a class="text-danger" id="edit_receipt" href="javascript:;" >修改</a></div>
            </div>
          </div>
        </if>

        <!-- 商品清单 -->
        <div class="page-header">
          <h3>商品清单</h3>
        </div>
        <div class="cart-list order-item-list">
          <dl>
            <dt class="clearfix">
              <div class="row">
                <span class="col-xs-7">商品信息</span>
                <span class="col-xs-1">单价</span>
                <span class="col-xs-2">数量</span>
                <span class="col-xs-2">小计</span>
              </div>
            </dt>
            <!-- 商品详情页s -->
            <div class="supplier-box">
              <dd class="supplier-dd">
                <div class="row">
                  <span class="col-xs-3">
                    <span class="check active"></span>
                    <gt name="data.store_id" value="0">{$data.store_name} <else /> <span class="is-self">自营</span></gt>
                  </span>
                  <span class="col-xs-6 send-items J_send_supp_{$data.supplier_id}"></span>
<!--                  <span class="col-xs-3 delivery-select">
                    配送方式：
                    <select name="delivery_id[{$data['supplier_id']}]" class="J_delivery_id">
                      <notempty name="data[delivery]">
                        <volist name="data[delivery]" id="d_li">
                          <option value="{$d_li.id}" data-price="{$d_li.price}">{$d_li.company}（运费{$d_li.price}元）</option>
                        </volist>
                      <else />
                        <option value="0" data-price="0">快递免邮</option>
                      </notempty>
                    </select>
                  </span>-->
                </div>
              </dd>
              <!-- 商品展示list -->
                <dd class="item">
                  <div class="row">
                    <div class="col-xs-7">
                      <div class="pic">
                        <a href="{:U('Item/detail', array('id' => $data['item_id']))}" target="_blank"><img src="{:get_image_thumb($data['cover_path'], 100, 100)}" alt="{$data.name}"></a>
                      </div>
                      <div class="info">
                        <div class="name"><a href="{:U('Item/detail', array('id' => $data['item_id']))}" target="_blank">{$data.name}</a></div>
                        <if condition="$data['stock'] lt $data['quantity']"><em class="text-danger">此商品所购买数量大于库存</em></if>
                        <notempty name="data.spec">
                          <div class="spec">
                            <volist name="data.spec" id="vl">
                              <span class="mr-sm">{$vl.key}：{$vl.val}</span>
                            </volist>
                          </div>
                        </notempty>
                      </div>
                    </div>
                    <div class="col-xs-1">
                      <div class="box price">
                          <span class="text-danger">
                            <em class="yen">&yen;</em> {$data.price}
                          </span>
                      </div>
                    </div>
                    <div class="col-xs-2">
                      <div class="box">&nbsp;&nbsp;x {$data.quantity}</div>
                    </div>
                    <div class="col-xs-2">
                      <div class="box price">
                        <strong class="text-danger"><em class="yen">&yen;</em> {$data['subAmount']}</strong>
                      </div>
                    </div>
                  </div>
                </dd>
            </div>
          </dl>
        </div>

        <div class="order-count clearfix">
          <!-- order-price -->
          <div class="order-price">
            <ul>
              <li>商品数量：<span>{$data.total_quantity} 件</span></li>
              <li>商品总价：<span id="J_total_amount">{$data.total_price} 元</span></li>
              <li>运费：<span id="J_delivery_fee">0.00 元</span></li>
            </ul>
            <p class="total">
              应付总额：<span class="text-danger"><strong id="J_total_price">0</strong>元</span>
            </p>
          </div>
        </div>
      <input type="hidden" id="J_delivery_fee_new" value="{$data['delivery'][$store_id]['price']}">
      <input type="hidden" name="delivery_fee" id="J_delivery_fee_count" value="">
        <input type="hidden" name="buynowss" id="buynow" value="{$buynow}">
        <input type="hidden" name="item_ids" id="J_item_ids" value="{$data['item_id']}">
        <div class="order-confirm">
          <div id="submitAddress"></div>
          <a href="javascript:;" class="pull-right btn btn-positive" id="J_order_submit">立即下单</a>
        </div>
      </div>
      <div class="address-edit-backdrop" id="J_editAddrBackdrop"></div>
    </div>
  </form>
  <include file="Order/invoice" />
</block>

<block name="script">
  {:hook('noticeMsg')}
  <script>
    seajs.use(['orderSkill', 'receiver', 'cart', 'invoice'], function(order, receiver, cart , invoice){
      var total_price = '{$data.total_price}';
      order.init(total_price);
      receiver.init();
      invoice.init();
    });
  </script>
</block>